package com.lx.oms.controller.manager.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.utils.Utils;
import com.lx.oms.controller.dao.BroadcastMapper;
import com.lx.oms.controller.entity.BroadcastEntity;
import com.lx.oms.controller.manager.BroadcastManager;

/**
 * 轮播图
 *
 * @author houzhong
 * @date 2018年7月06日 下午1:55:51
 */
@Component("broadcastManager")
public class BroadcastManagerImpl implements BroadcastManager {

	@Autowired
	private BroadcastMapper broadcastMapper;
	

	@Override
	public List<BroadcastEntity> listBroadcast(Page<BroadcastEntity> page, Query search) {
		return broadcastMapper.listForPage(page, search);
	}

	@Override
	public int saveBroadcast(BroadcastEntity broadcast) {
		if (broadcast.getId() == null) {
			broadcast.setId(Utils.id().toString());
		}
		return broadcastMapper.save(broadcast);
	}

	@Override
	public BroadcastEntity getBroadcastById(BigInteger id) {
		BroadcastEntity tBroadcast = broadcastMapper.getObjectById(id);
		return tBroadcast;
	}

	@Override
	public int updateBroadcast(BroadcastEntity broadcast) {
		return broadcastMapper.update(broadcast);
	}

	@Override
	public int batchRemove(String[] id) {
		int count = broadcastMapper.batchRemove(id);
		return count;
	}
	
}
